<?php 
	
	/**
	* Room
	*/
	class Player
	{
		public $id;       // 
		public $qqid;
		public $nickname; 	   // 
		public $inithp;
		public $initmp;
		public $hp;   // 
		public $mp; //
		public $attr;
		
		public $handcard = [];  // 手牌
		public $cards = []; 	   //卡池
		public $qipai = [];	   //弃牌堆
		public $removecard = []; // 本局游戏移除的牌
		public $isuser;    // 是否真人
		public $cardindex = 1;

		function __construct($nickname="昵称",$hp=10,$mp=10,$attr = "描述为空",$qqid,$isuser = 1)
		{
			# code...
			$this->qqid = $qqid;
			$this->nickname = $nickname;
			$this->hp = $hp;
			$this->mp = $mp;
			$this->inithp = $hp;
			$this->initmp = $mp;
			$this->attr = $attr;
			$this->isuser = $isuser;
		}

		public function initcards($cards){
			foreach ($cards as  $value) {
				$this->cards[$value['id']] = $value;
			}
		}

		public function addcards($cards){
			$cardsname = explode(",",$cards);
			foreach ($cardsname as $value) {
				$card = [];
				$id = "c_".$this->cardindex;
				$card['id'] = $id;
				$card['fromqq'] = $this->qqid;
				$card['c_name'] = $value;
				$card['effect'] = "暂无";
				$this->qipai[$id] = $card;
				$this->cardindex += 1;
			}
		}

		public function roundend(){
			// $this->qipai = [];
			$this->qipai = $this->qipai + $this->handcard;
			$this->handcard = [];
		}

		public function playerformatInfo(){
			return "id: " . $this->qqid . ",  name: " . $this->nickname . ",  hp: " . $this->hp ."/".$this->inithp.",  mp: " . $this->mp . "/" . $this->initmp;
			return "a";
		}


	}
?>